﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        SqlHelper sqlHelper = new SqlHelper();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = TextBox1.Text;
            string pwd = TextBox2.Text;
            string email = TextBox3.Text;
            string intro = TextBox4.Text;

            string sql = "insert into StudentInfo (stu_name,password,email,intro) values(@name,@pwd,@email,@intro)";

            SqlParameter[] pars =
                {
                new SqlParameter("@name",name),
                new SqlParameter("@pwd",pwd),
                new SqlParameter("@email",email),
                new SqlParameter("@intro",intro)

                };
            DataTable dt = sqlHelper.Get(sql, pars);
            if (dt.Rows.Count>0)//判断可读的记录条数是否大于0
            {
                Literal1.Text = "注册成功 <a href='WebForm1.aspx'>去登录</a>";
            }
            else
            {
                Literal1.Text = "注册失败";
            }

        }
    }
}